<!--
 * @Author: CHINAKAIYUAN<sunkaiyuan@namenode.cn>
 * @Date: 2022-02-03 14:41:20
 * @LastEditTime: 2023-10-18 13:02:34
 * @LastEditors: 孙开源 && sunkaiyuan@namenode.cn
 * @Description:   :gridOps="gridOptions" 
-->
<template>
  <sc-VxeTable ref="xGrid1" :gridEvts="gridEvents" :tablecode="'comprehensive_car'"
    :url="this.$API.comprehensive.car.list">
  </sc-VxeTable>

  <save-dialog v-if="dialog.save" ref="saveDialog" @success="handleSuccess" @closed="dialog.save = false">
  </save-dialog>

  <car v-if="dialog.car" ref="carDialog" @success="handleSuccess" @closed="dialog.car = false">
  </car>
</template>
<script>
// import { useRouter } from "vue-router";
// import { VXETable } from 'vxe-table'; 
import SaveDialog from "./save";
import car from "./car";
export default {
  name: "comprehensive_car",
  components: {
    SaveDialog,
    car
  },
  data() {
    return {
      dialog: {
        save: false,
        car: false
      },
      gridEvents: {
        cellDblclick: ({ row }) => {
          this.edit(row);
        },
        add: () => {
          this.add();
        },
        edit: ({ button }) => {
          this.edit(button.selectRecords[0]);
        },
        addItem: () => {
          this.addItem();
        },
      },
    };
  },
  methods: {
    addItem: function () {
      this.dialog.car = true;
      this.$nextTick(() => {
        this.$refs.carDialog.open();
      });
    },
    add: function () {
      this.dialog.save = true;
      this.$nextTick(() => {
        this.$refs.saveDialog.open();
      });
    },

    handleSuccess() {
      this.$refs.xGrid1.refresh();
    },
    edit(item) {
      this.dialog.save = true;
      this.$nextTick(() => {
        this.$refs.saveDialog.open("edit").setData(item);
      });
    },

  },
};
</script>
